package Singleton;


import java.util.Hashtable;

public class MyFruitStore {
    //new Hashtable<Integer,MyFruit>();
    private static Hashtable fruittable= null;
    private static MyFruitStore fruitstore = null;
    private MyFruitStore() {
        fruittable = new Hashtable<Integer,MyFruit>();
    }

    public static MyFruitStore GetFruitStore() {
        if(fruitstore == null) {
            fruitstore = new MyFruitStore();
        }
        return fruitstore;
    }



    public void Add(Integer key, MyFruit fruit) {
        //放水果
        fruittable.put(key, fruit);

    }
    public static MyFruit Get(Integer key) {
        MyFruit fruit = (MyFruit)fruittable.get(key);
        return (MyFruit)fruit.clone();
    }

}

